﻿
namespace AnnouncementServices
{
    using System;
    using System.Collections.Generic;
    using System.ComponentModel;
    using System.ComponentModel.DataAnnotations;
    using System.Linq;
    using System.Web.Ria;
    using System.Web.Ria.Data;
    using System.Web.DomainServices;
    using System.Data.Linq;
    using System.Web.DomainServices.LinqToSql;


    // Implements application logic using the AnnouncementDataClassesDataContext context.
    // TODO: Add your application logic to these methods or in additional methods.
    [EnableClientAccess()]
    public class AnnouncementDomainService : LinqToSqlDomainService<AnnouncementDataClassesDataContext>
    {

        // TODO: Consider
        // 1. Adding parameters to this method and constraining returned results, and/or
        // 2. Adding query methods taking different parameters.
        public IQueryable<Announcement> GetAnnouncements()
        {
            return this.Context.Announcements;
        }

        public void InsertAnnouncement(Announcement announcement)
        {
            this.Context.Announcements.InsertOnSubmit(announcement);
        }

        public void UpdateAnnouncement(Announcement currentAnnouncement)
        {
            this.Context.Announcements.Attach(currentAnnouncement, this.ChangeSet.GetOriginal(currentAnnouncement));
        }

        public void DeleteAnnouncement(Announcement announcement)
        {
            this.Context.Announcements.Attach(announcement);
            this.Context.Announcements.DeleteOnSubmit(announcement);
        }
    }
}


